using System.Collections.Generic;
using Kopernikus.Parsing.GenericLexing;
using Kopernikus.Parsing.Lexing;
using NUnit.Framework;

namespace Kopernikus.Parsing.Tests.GenericLexing
{
    [TestFixture]
    public class TestTerminalLexing
    {
        private class L
        {
            [Lex("id", "[a-z]+")]
            public string t_id(LexerMatch m)
            {
                return "id(" + m.Value + ")";
            }

            [Lex("num", "\\d+")]
            public string t_num(LexerMatch m)
            {
                return "num(" + m.Value + ")";
            }
        }

        [Test]
        public void Test()
        {
            GenericLexer<L, string> lexer = GenericLexer<L, string>.Create(new L());
            List<string> l = new List<string>(lexer.Scan("a1b2cde34"));
            Assert.AreEqual("id(a),num(1),id(b),num(2),id(cde),num(34)", string.Join(",", l.ToArray()));
        }
    }
}